//
//  FMSelectTableViewCell.m
//  PsychologyFM
//
//  Created by 杜建虎 on 16/1/14.
//  Copyright © 2016年 ZhangLuDu. All rights reserved.
//

#import "FMSelectTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation FMSelectTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, kScreenWidth / 7, kScreenWidth / 7)];
        [self.contentView addSubview:_iconImage];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImage.frame.size.width + 20, 12, kScreenWidth - self.iconImage.frame.size.width - 25, 15)];
        _titleLabel.font = [UIFont systemFontOfSize:14];
        [self.contentView addSubview:_titleLabel];
        
        _antorLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.origin.y + _titleLabel.frame.size.height + 3,kScreenWidth / 3,15)];
        _antorLabel.textColor = [UIColor grayColor];
        _antorLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_antorLabel];


        _listenLabel = [[UILabel alloc] initWithFrame:CGRectMake(_titleLabel.frame.origin.x,_titleLabel.frame.origin.y + _titleLabel.frame.size.height + 15,kScreenWidth / 3,22)];
        _listenLabel.textColor = [UIColor grayColor];
        _listenLabel.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_listenLabel];
    }
    return self;
}

- (void)setModel:(FMFindCellModel *)model
{
    _model = model;
    _titleLabel.text = model.title;
    [_iconImage sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:nil];
    _antorLabel.text =  [NSString stringWithFormat:@"主播 %@",model.speak];
    _listenLabel.text = [NSString stringWithFormat:@"收听量: %@",model.viewnum];
}

- (void)setHomeModel:(FMLessonAndFMModel *)homeModel
{
    _homeModel = homeModel;
    _titleLabel.text = homeModel.title;
    _iconImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:homeModel.cover]]];
    _antorLabel.text =  [NSString stringWithFormat:@"主播 %@",homeModel.speak];
    _listenLabel.text = [NSString stringWithFormat:@"收听量: %@",homeModel.viewnum];
}

@end
